package com.dq.domain.org.centre;

import com.dq.vo.baseVo.VO;
import com.dq.domain.base.BaseEntity;

import com.dq.domain.position.OrgPosition;
import com.dq.domain.sys.section.SysSection;
import com.dq.utils.TimeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;

/**
 * @author cf
 */
@Data
@Entity
@ApiModel("岗位门店关联表")
public class OrgDeptPositionCentre extends BaseEntity implements VO.ToVO {

    @ManyToOne
    @ApiModelProperty("岗位")
    protected OrgPosition orgPosition;
    @ManyToOne
    @ApiModelProperty("组织部门")
    protected SysSection org;

    @Data
    @ApiModel(value = "岗位视图")
    public static class Vo implements VO {
        protected Long id;
        @ApiModelProperty(value = "岗位编号")
        private String ordersNo;
        protected Long orgPositionId;
        @ApiModelProperty("岗位名称")
        protected String postName;
        @ApiModelProperty("描述")
        protected String depict;
        @ApiModelProperty(value = "创建时间")
        private String createTime;
        @ApiModelProperty(value = "修改时间")
        private String lastModifyTime;
        @ApiModelProperty(value = "创建者id")
        private Long createUserId;
        @ApiModelProperty(value = "创建者name")
        private String createUserName;
        @ApiModelProperty(value = "修改者id")
        private Long updateUserId;
        @ApiModelProperty(value = "修改者name")
        private String updateUserName;
    }

    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        vo.id = this.id;
        vo.orgPositionId = this.getOrgPosition().getId();
        vo.ordersNo = this.getOrgPosition().getOrdersNo();
        vo.postName = this.getOrgPosition().getPostName();
        vo.depict = this.getOrgPosition().getDepict();
        vo.createTime = TimeUtil.longToString(this.createTime, TimeUtil.YYYY_MM_DD_HH_MM_SS);
        vo.lastModifyTime = TimeUtil.longToString(this.lastModifyTime, TimeUtil.YYYY_MM_DD_HH_MM_SS);

        vo.createUserId = this.createUser == null ? null : this.createUser.getId();
        vo.createUserName = this.createUser == null ? null : this.createUser.getUsername();
        vo.updateUserId = this.updateUser == null ? null : this.updateUser.getId();
        vo.updateUserName = this.updateUser == null ? null : this.updateUser.getUsername();
        return vo;
    }

}
